package breeze.lepei.der.usersettings;
import android.content.Context;
import android.content.SharedPreferences;

public class UserSettings implements IUserSettings {

	@Override
	public void setNotice(String s) {
		ps("notice",s);
	}

	@Override
	public String getNotice() {
		return gs("notice","");
	}

	@Override
	public void setQQ(String s) {
		ps("qq",s);
	}

	@Override
	public String getQQ() {
		return gs("qq","");
	}

	@Override
	public void setRid(String s) {
		ps("rid",s);
	}

	@Override
	public String getRid() {
		return gs("rid","");
	}

	@Override
	public void setStudentId(String s) {
		ps("studentId",s);
	}

	@Override
	public String getStudentId() {
		return gs("studentId","");
	}

	@Override
	public void setSchoolName(String s) {
		ps("schoolName",s);
	}

	@Override
	public String getSchoolName() {
		return gs("schoolName","");
	}

	@Override
	public void setStudentName(String s) {
		ps("studentName",s);
	}

	@Override
	public String getStudentName() {
		return gs("studentName","");
	}

	@Override
	public void setGrade(String s) {
		ps("grade",s);
	}

	@Override
	public String getGrade() {
		return gs("grade","");
	}

	@Override
	public void setClassCode(String s) {
		ps("classCode",s);
	}

	@Override
	public String getClassCode() {
		return gs("classCode","");
	}

	@Override
	public void setClassName(String s) {
		ps("className",s);
	}

	@Override
	public String getClassName() {
		return gs("className","");
	}
	

	@Override
	public void logOut() {
		sp.edit().clear().commit();
	}

	@Override
	public void ps(String key, String content) {
		sp.edit().putString(key,content).commit();
	}

	@Override
	public String gs(String key, String df) {
		return sp.getString(key,df);
	}

	@Override
	public void setToken(String token) {
		ps("token",token);
	}

	@Override
	public String getToken() {
		return gs("token","");
	}

	@Override
	public void setVi(String vi) {
		ps("vi",vi);
	}

	@Override
	public String getVi() {
		return gs("vi","");
	}

	@Override
	public void setUserPhone(String phone) {
		sp.edit().putString("phone",phone).commit();
	}

	@Override
	public String getUserPhone() {
		return sp.getString("phone","");
	}

	@Override
	public void setUserPass(String password) {
		sp.edit().putString("password",password).commit();
	}

	@Override
	public String getUserPass() {
		return sp.getString("password","");
	}
    
	private static SharedPreferences sp;
	private static UserSettings settings;
	
	/**
	*@author BREEZE
	*@description 初始化类
	*@param 上下文
	*/
	public UserSettings(Context context){
		sp=context.getSharedPreferences("user_settings",Context.MODE_PRIVATE);
	}
	
	/**
	*@author BREEZE
	*@description 获取本类实例
	*@param 上下文
	*@return 本类
	*/
	public static UserSettings getInstance(Context context){
		if(settings==null){
			settings=new UserSettings(context);
		}
		return settings;
	}
	
	
	
	
	
}
